﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DA
{
    public class BomDA:BaseConnection
    {
        public SqlDataAdapter danhSachBomSanPhamAdapter { set; get; }
        public BomDA()
        { 
        
        }

        public DataSet timKiemBomSanPham(string maSanPham)
        {
            DataSet ds = new DataSet();
            String sqlStm = "SELECT MaSanPham, MaBanThanhPham, MoTa, KhoiLuong";
            sqlStm += " FROM BOM ";
            sqlStm += " WHERE MaSanPham = '" + maSanPham + "'";

            openConnect();
            SqlCommand cmd = new SqlCommand(sqlStm, con);
            danhSachBomSanPhamAdapter = new SqlDataAdapter(cmd);
            danhSachBomSanPhamAdapter.SelectCommand = cmd;
            SqlCommandBuilder sqlBuilder = new SqlCommandBuilder(danhSachBomSanPhamAdapter);
            danhSachBomSanPhamAdapter.Fill(ds, "BOM");
            closeConnect();
            return ds;

        }
    }

}
